package com.mxx.tomcat;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mxx.common.conv.CustomObjectMapper;
import com.mxx.common.conv.JacksonConverter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: Mr. Zeng
 * @Date: 2021/4/8 20:16
 * @Description: 暂无描述
 */
@Configuration
public class WebCoreBeanAutoConfiguration {


    @Bean
    @ConditionalOnMissingBean(value = CustomObjectMapper.class)
    public CustomObjectMapper objectMapper() {
        return new CustomObjectMapper();
    }

    @Bean
    @ConditionalOnMissingBean(value = ResponseWriter.class)
    public ResponseWriter responseWriter(CustomObjectMapper customObjectMapper) {
        return new ResponseWriter(customObjectMapper);
    }

    @Bean
    @ConditionalOnMissingBean(value = JacksonConverter.class)
    public JacksonConverter jacksonConverter(ObjectMapper objectMapper) {
        return  JacksonConverter.getInstance(objectMapper);
    }
}
